import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import { setToken,setRefreshToken } from './utils/auth'


Vue.config.productionTip = false

ElementUI.Dialog.props.closeOnClickModal.default = false

Vue.use(ElementUI)



new Vue({
  router,
  store,
  created(){
    let obj = this.getRequest()
    console.log(obj);
    setToken(obj["access_token"])
    setRefreshToken(obj["refresh_token"])
  },
  methods:{
    getRequest() {
      var args = new Object();
      var query = location.href.split('?')[1]//获取查询串 
      var pairs = query.split("&");//在逗号处断开 
      for (var i = 0; i < pairs.length; i++) {
          var pos = pairs[i].indexOf('=');//查找name=value 
          if (pos == -1) {//如果没有找到就跳过 
              continue;
          }
          var argname = pairs[i].substring(0, pos);//提取name 
          var value = pairs[i].substring(pos + 1);//提取value 
          args[argname] = unescape(value);//存为属性 
      }
      return args;//返回对象 
  }
  },
  render: h => h(App)
}).$mount('#app')
